package com.yuan.springcloud.user.config;

import lombok.extern.slf4j.Slf4j;
import org.jasypt.encryption.StringEncryptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

/**
 * Spring启动完成自动执行任务
 * @author YouYuan
 * @date 2020/8/11 1:58
 */
@Slf4j
@Component
public class UserAppOnRunExec implements CommandLineRunner {

    @Autowired
    private StringEncryptor stringEncryptor;

    @Autowired
    private ApplicationContext applicationContext;

    @Override
    public void run(String... args) throws Exception {
        log.info("[UserAppOnRunExec]Start...");
//        Environment environment = applicationContext.getEnvironment();
//        String property = environment.getProperty("spring.redis.host");
//        log.info("[Jasypt加密密文]：{}", stringEncryptor.encrypt(property));
    }
}
